const fs = require('fs');
let config;

/**
 * 判断环境
 */
if (process.env.NODE_ENV == 'production') {
    config = require('./config/config_prod');
} else {
    config = require('./config/config_dev');
}

/**
 * 检查并创建目录
 */
let paths = {
    logs: __dirname + '/logs/',
    bower: __dirname + '/bower_components/',
    private: __dirname + '/private/',
    public: __dirname + '/public/',
    client: __dirname + '/client/',
    dist: __dirname + '/dist/',
    json: __dirname + '/private/json/',
    download: __dirname + '/private/download/',
    upload: __dirname + '/public/upload/',
    qrcode: __dirname + '/private/qrcode/',
}
for (let i in paths) {
    let path = paths[i];
    fs.existsSync(path) || fs.mkdirSync(path);
}

config.paths = paths;
module.exports = config;